Part Number Hot Search : 
MC788 LH28F 01118 LBS08804 SPLM393 MJD42C1G S10S04MR E001169
Product Description
Full Text Search
 

To Download ATTINY22L-1SI Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  1 features ? utilizes the avr ? risc architecture  avr - high-performance and low-power risc architecture ? 118 powerful instructions - most single clock cycle execution ? 32 x 8 general purpose working registers ? up to 1mips throughput at 1mhz  data and nonvolatile program memory ? 2k bytes of in-system programmable flash endurance 1,000 write/erase cycles ? 128 bytes of internal sram ? 128 bytes of in-system programmable eeprom endurance: 100,000 write/erase cycles ? programming lock for flash program and eeprom data security  peripheral features ? one 8-bit timer/counter with separate prescaler ? programmable watchdog timer with on-chip oscillator ? spi serial interface for in-system programming  special microcontroller features ? low-power idle and power down modes ? external and internal interrupt sources ? power-on reset circuit ? on-chip rc oscillator  specifications ? low-power, high-speed cmos process technology ? fully static operation  power consumption at 3v, 25 c ? active: 1.5 ma ? idle mode: 100 a ? power down mode: <1 a  i/o and packages ? 5 programmable i/o lines ? 8-pin pdip and soic  operating voltages ? 2.7 - 6.0v  speed grade ? internal oscillator ~1mhz @ 5.0v description the attiny22l is a low-power cmos 8-bit microcontroller based on the avr risc architecture. by executing powerful instructions in a single clock cycle, the attiny22l achieves throughputs approaching 1 mips per mhz allowing the system designer to optimize power consumption versus processing speed. the avr core combines a rich instruction set with 32 general purpose working regis- ters. all the 32 registers are directly connected to the arithmetic logic unit (alu), rev. 1273b ? 02/00 8-bit microcontroller with 2k bytes of in-system programmable flash attiny22l preliminary pin configuration pdip/soic 1 2 3 4 8 7 6 5 reset pb3 pb4 gnd vcc pb2 (sck/t0) pb1 (miso/int0) pb0 (mosi)
2 attiny22l allowing two independent registers to be accessed in one single instruction executed in one clock cycle. the resulting architecture is more code efficient while achieving throughputs up to ten times faster than conventional cisc microcontrollers. block diagram figure 1. the attiny22l block diagram program counter internal oscillator watchdog timer stack pointer program flash mcu control register sram general purpose registers instruction register timer/ counter instruction decoder data dir. reg. portb data register portb programming logic timing and control interrupt unit eeprom spi status register z y x alu portb drivers pb0 - pb4 reset vcc gnd control lines 8-bit data bus
3 attiny22l the attiny22l provides the following features: 2k bytes of in-system programmable flash, 128 bytes eeprom, 128 bytes sram, five general purpose i/o lines, 32 general purpose working registers, an 8-bit timer/counter, internal and external interrupts, programmable watchdog timer with internal oscillator, an spi serial port for flash memory download- ing and two software selectable power saving modes. the idle mode stops the cpu while allowing the sram, timer/counters, spi port and interrupt system to continue functioning. the power down mode saves the register contents but freezes the oscillator, disabling all other chip functions until the next interrupt or hardware reset. the device is manufactured using atmel ? s high density nonvolatile memory technology. the on-chip flash allows the program memory to be reprogrammed in-system through an spi serial interface. by combining an 8-bit risc cpu with isp flash on a monolithic chip, the atmel attiny22l is a powerful microcontroller that provides a highly flexible and cost effec- tive solution to many embedded control applications. the attiny22l avr is supported with a full suite of program and system development tools including: c compilers, macro assemblers, program debugger/simulators, in-circuit emulators, and evaluation kits. pin descriptions attiny22l vcc supply voltage pin. gnd ground pin. port b (pb4..pb0) port b is a 5-bit bi-directional i/o port with internal pull-up resistors. the port b output buffers can sink 20 ma. as inputs, port b pins that are externally pulled low, will source current if the pull-up resistors are activated. port b also serves the functions of various special features. port pins can provide internal pull-up resistors (selected for each bit). the port b pins are tri-stated when a reset condition becomes active. reset reset input. an external reset is generated by a low level on the reset pin. reset pulses longer than 50 ns will generate a reset, even if the clock is not running. shorter pulses are not guaranteed to generate a reset. clock source the attiny22l is clocked by an on-chip rc oscillator. this rc oscillator runs at a nominal frequency of 1 mhz (vcc = 5v). architectural overview the fast-access register file concept contains 32 x 8-bit general purpose working registers with a single clock cycle access time. this means that during one single clock cycle, one arithmetic logic unit (alu) operation is executed. two operands are output from the register file, the operation is executed, and the result is stored back in the register file in one clock cycle. six of the 32 registers can be used as three 16-bit indirect address register pointers for data space addressing enabling efficient address calculations. one of the three address pointers is also used as the address pointer for the constant table look up function. these added function registers are the 16-bit x-register, y-register and z-register.
4 attiny22l figure 2. the attiny22l avr risc architecture the alu supports arithmetic and logic functions between registers or between a constant and a register. single register operations are also executed in the alu. figure 2 shows the attiny22l avr risc microcontroller architecture. in addition to the register operation, the conventional memory addressing modes can be used on the register file as well. this is enabled by the fact that the register file is assigned the 32 lowermost data space addresses ($00 - $1f), allowing them to be accessed as though they were ordinary memory locations. the i/o memory space contains 64 addresses for cpu peripheral functions as control registers, timer/counters, a/d-converters, and other i/o functions. the i/o memory can be accessed directly, or as the data space locations follow- ing those of the register file, $20 - $5f. the avr has harvard architecture - with separate memories and buses for program and data. the program memory is accessed with a two stage pipeline. while one instruction is being executed, the next instruction is pre-fetched from the program memory. this concept enables instructions to be executed in every clock cycle. the program memory is in-system downloadable flash memory. with the relative jump and call instructions, the whole 1k address space is directly accessed. most avr instructions have a single 16-bit word format. every program memory address contains a 16- or 32-bit instruction. during interrupts and subroutine calls, the return address program counter (pc) is stored on the stack. the stack is effectively allocated in the general data sram, and consequently the stack size is only limited by the total sram size and the usage of the sram. all user programs must initialize the sp in the reset routine (before subroutines or interrupts are executed). the 8-bit stack pointer sp is read/write accessible in the i/o space. the 128 bytes data sram + register file and i/o registers can be easily accessed through the five different addressing modes supported in the avr architecture. the memory spaces in the avr architecture are all linear and regular memory maps. 1k x 16 program flash instruction register instruction decoder program counter control lines 32 x 8 general purpose registers alu status and test control registers interrupt unit spi unit 8-bit timer/counter watchdog timer i/o lines 128 x 8 eeprom data bus 8-bit avr attiny22l architecture 128 x 8 data sram direct addressing indirect addressing
5 attiny22l figure 3. memory maps a flexible interrupt module has its control registers in the i/o space with an additional global interrupt enable bit in the st atus register. all the different interrupts have a separate interrupt vector in the interrupt vector table at the beginning of the program memory. the different interrupts have priority in accordance with their interrupt vector position. the lower the interrupt vector address, the higher the priority. eeprom (128 x 8) $000 $07f eeprom data memory
6 attiny22l general purpose register file figure 4 shows the structure of the 32 general purpose registers in the cpu. figure 4. avr cpu general purpose working registers all the register operating instructions in the instruction set have direct and single cycle access to all registers. the only exception is the five constant arithmetic and logic instructions sbci, subi, cpi, andi, ori between a constant and a register and the ldi instruction for load immediate constant data. these instructions apply to the second half of the regis- ters in the register file - r16..r31. the general sbc, sub, cp, and, or and all other operations between two registers or on a single register apply to the entire register file. as shown in figure 4, each register is also assigned a data memory address, mapping them directly into the first 32 loca- tions of the user data space. although the register file is not physically implemented as sram locations, this memory organization provides great flexibility in access of the registers, as the x, y and z registers can be set to index any registe r in the file. 7 0 addr. r0 $00 r1 $01 r2 $02 ? r13 $0d general r14 $0e purpose r15 $0f working r16 $10 registers r17 $11 ? r26 $1a x-register low byte r27 $1b x-register high byte r28 $1c y-register low byte r29 $1d y-register high byte r30 $1e z-register low byte r31 $1f z-register high byte
7 attiny22l x-register, y-register, and z-register the registers r26..r31 have some added functions to their general purpose usage. these registers are the address point- ers for indirect addressing of the data space. the three indirect address registers x, y and z are defined as: figure 5. the x, y, and z registers in the different addressing modes these address registers have functions as fixed displacement, automatic increment and decrement (see the descriptions for the different instructions). alu - arithmetic logic unit the high-performance avr alu operates in direct connection with all the 32 general purpose working registers. within a single clock cycle, alu operations between registers in the register file are executed. the alu operations are divided into three main categories - arithmetic, logic and bit-functions in-system programmable flash program memory the attiny22l contains 2k bytes on-chip in-system programmable flash memory for program storage. since all instruc- tions are 16- or 32-bit words, the flash is organized as 1k x 16. the flash memory has an endurance of at least 1000 write/erase cycles. the attiny22l program counter pc is 10 bits wide, hence addressing the 1024 program memory addresses. see page 38 for a detailed description on flash data programming. constant tables must be allocated within the address 0-2k (see the lpm - load program memory instruction description). see page 9 for the different addressing modes. eeprom data memory the attiny22l contains 128 bytes of eeprom data memory. it is organized as a separate data space, in which single bytes can be read and written. the eeprom has an endurance of at least 100,000 write/erase cycles. the access between the eeprom and the cpu is described on page 30 specifying the eeprom address register, the eeprom data register, and the eeprom control register. for the spi data downloading, see page 38 for a detailed description. 15 0 x - register 7 0 7 0 r27 ($1b) r26 ($1a) 15 0 y - register 7 0 7 0 r29 ($1d) r28 ($1c) 15 0 z - register 7 0 7 0 r31 ($1f) r30 ($1e)
8 attiny22l sram data memory the following figure shows how the attiny22l data memory is organized: figure 6. sram organization the 224 data memory locations address the register file, i/o memory and the data sram. the first 96 locations address the register file + i/o memory, and the next 128 locations address the data sram. the five different addressing modes for the data memory cover: direct, indirect with displacement, indirect, indirect with pre-decrement and indirect with post-increment. in the register file, registers r26 to r31 feature the indirect addressing pointer registers. the direct addressing reaches the entire data address space. the indirect with displacement mode features 63 address locations reach from the base address given by the y and z register. when using register indirect addressing modes with automatic pre-decrement and post-increment, the address registers x, y and z are used and decremented and incremented. the 32 general purpose working registers, 64 i/o registers and the 128 bytes of data sram in the attiny22l are all directly accessible through all these addressing modes. register file data address space r0 $00 r1 $01 r2 $02 ?? r29 $1d r30 $1e r31 $1f i/o registers $00 $20 $01 $21 $02 $22 ?? $3d $5d $3e $5e $3f $5f internal sram $60 $61 $62 ? $dd $de $df
9 attiny22l program and data addressing modes the attiny22l avr risc microcontroller supports powerful and efficient addressing modes for access to the program memory (flash) and data memory. this section describes the different addressing modes supported by the avr architec- ture. in the figures, op means the operation code part of the instruction word. to simplify, not all figures show the exact location of the addressing bits. register direct, single register rd figure 7. direct single register addressing the operand is contained in register d (rd). register direct, two registers rd and rr figure 8. direct register addressing, two registers operands are contained in register r (rr) and d (rd). the result is stored in register d (rd).
10 attiny22l i/o direct figure 9. i/o direct addressing operand address is contained in 6 bits of the instruction word. n is the destination or source register address. data direct figure 10. direct data addressing a 16-bit data address is contained in the 16 lsbs of a two-word instruction. rd/rr specify the destination or source register.
11 attiny22l data indirect with displacement figure 11. data indirect with displacement operand address is the result of the y or z-register contents added to the address contained in 6 bits of the instruction word. data indirect figure 12. data indirect addressing operand address is the contents of the x, y or the z-register.
12 attiny22l data indirect with pre-decrement figure 13. data indirect addressing with pre-decrement the x, y or the z-register is decremented before the operation. operand address is the decremented contents of the x, y or the z-register. data indirect with post-increment figure 14. data indirect addressing with post-increment the x, y or the z-register is incremented after the operation. operand address is the content of the x, y or the z-register prior to incrementing.
13 attiny22l constant addressing using the lpm instruction figure 15. code memory constant addressing constant byte address is specified by the z-register contents. the 15 msbs select word address (0 - 1k), the lsb selects low byte if cleared (lsb = 0) or high byte if set (lsb = 1). indirect program addressing, ijmp and icall figure 16. indirect program memory addressing program execution continues at address contained by the z-register (i.e., the pc is loaded with the content of the z-register).
14 attiny22l relative program addressing, rjmp and rcall figure 17. relative program memory addressing program execution continues at address pc + k + 1. the relative address k is -2048 to 2047. memory access and instruction execution timing this section describes the general access timing concepts for instruction execution and internal memory access. the avr cpu is driven by the system clock ? , directly generated from the internal rc oscillator. no internal clock division is used. figure 18. the parallel instruction fetches and instruction executions figure 18 shows the parallel instruction fetches and instruction executions enabled by the harvard architecture and the fast-access register file concept. this is the basic pipelining concept to obtain up to 1 mips per mhz with the corresponding unique results for functions per cost, functions per clocks, and functions per power-unit. 1 system clock ? 1st instruction fetch 1st instruction execute 2nd instruction fetch 2nd instruction execute 3rd instruction fetch 3rd instruction execute 4th instruction fetch t1 t2 t3 t4
15 attiny22l figure 19. single cycle alu operation figure 19 shows the internal timing concept for the register file. in a single clock cycle an alu operation using two register operands is executed, and the result is stored back to the destination register. figure 20. on-chip data sram access cycles the internal data sram access is performed in two system clock cycles as described in figure 20. system clock ? total execution time register operands fetch alu operation execute result write back t1 t2 t3 t4 system clock ? wr rd data data address address t1 t2 t3 t4 prev. address read write
16 attiny22l i/o memory the i/o space definition of the attiny22l is shown in the following table: note: reserved and unused locations are not shown in the table. all the different attiny22l i/o and peripherals are placed in the i/o space. the different i/o locations are accessed by the in and out instructions transferring data between the 32 general purpose working registers and the i/o space. i/o registers within the address range $00 - $1f are directly bit-accessible using the sbi and cbi instructions. in these registers, the value of single bits can be checked by using the sbis and sbic instructions. refer to the instruction set chapter for more details. when using the i/o specific commands in, out the i/o addresses $00 - $3f must be used. when addressing i/o registers as sram, $20 must be added to this address. all i/o register addresses throughout this document are shown with the sram address in parentheses. for compatibility with future devices, reserved bits should be written to zero if accessed. reserved i/o memory addresses should never be written. some of the status flags are cleared by writing a logical one to them. note that the cbi and sbi instructions will operate on all bits in the i/o register, writing a one back into any flag read as set, thus clearing the flag. the cbi and sbi instruction s work with registers $00 to $1f only. the different i/o and peripherals control registers are explained in the following sections. status register - sreg the avr status register - sreg - at i/o space location $3f ($5f) is defined as: table 1. attiny22l i/o space address hex name function $3f ($5f) sreg status register $3d ($5d) spl stack pointer low $3b ($5b) gimsk general interrupt mask register $3a ($5a) gifr general interrupt flag register $39 ($59) timsk timer/counter interrupt mask register $38 ($58) tifr timer/counter interrupt flag register $35 ($55) mcucr mcu control register $34 ($54) mcusr mcu status register $33 ($53) tccr0 timer/counter 0 control register $32 ($52) tcnt0 timer/counter 0 (8-bit) $21 ($41) wdtcr watchdog timer control register $1e ($3e) eear eeprom address register $1d ($3d) eedr eeprom data register $1c ($3c) eecr eeprom control register $18 ($38) portb data register, port b $17 ($37) ddrb data direction register, port b $16 ($36) pinb input pins, port b bit 76543210 $3f ($5f) i t h s v n z c sreg read/write r/w r/w r/w r/w r/w r/w r/w r/w initial value 0 0 0 0 0 0 0 0
17 attiny22l  bit 7 - i: global interrupt enable the global interrupt enable bit must be set (one) for the interrupts to be enabled. the individual interrupt enable control is then performed in separate control registers. if the global interrupt enable register is cleared (zero), none of the interrupts are enabled independent of the individual interrupt enable settings. the i-bit is cleared by hardware after an interrupt has occurred, and is set by the reti instruction to enable subsequent interrupts.  bit 6 - t: bit copy storage the bit copy instructions bld (bit load) and bst (bit store) use the t bit as source and destination for the operated bit. a bit from a register in the register file can be copied into t by the bst instruction, and a bit in t can be copied into a bit i n a register in the register file by the bld instruction.  bit 5 - h: half carry flag the half carry flag h indicates a half carry in some arithmetic operations. see the instruction set description for detailed information.  bit 4 - s: sign bit, s = n v the s-bit is always an exclusive or between the negative flag n and the two ? s complement overflow flag v. see the instruc- tion set description for detailed information.  bit 3 - v: two ? s complement overflow flag the two ? s complement overflow flag v supports two ? s complement arithmetics. see the instruction set description for detailed information.  bit 2 - n: negative flag the negative flag n indicates a negative result from an arithmetical or logical operation. see the instruction set description for detailed information.  bit 1 - z: zero flag the zero flag z indicates a zero result from an arithmetical or logical operation. see the instruction set description for detailed information.  bit 0 - c: carry flag the carry flag c indicates a carry in an arithmetical or logical operation. see the instruction set description for detailed information. note that the status register is not automatically stored when entering an interrupt routine and restored when returning from an interrupt routine. this must be handled by software. stack pointer - spl an 8-bit register at i/o address $3d ($5d) forms the stack pointer of the attiny22l. 8 bits are used to address the 128 bytes of sram in locations $60 - $df. the stack pointer points to the data sram stack area where the subroutine and interrupt stacks are located. this stack space in the data sram must be defined by the program before any subroutine calls are executed or interrupts are enabled. the stack pointer must be set to point above $60. the stack pointer is decremented by one when data is pushed onto the stack with the push instruction, and it is decremented by two when an address is pushed onto the stack with subroutine calls and interrupts. the stack pointer is incremented by one when data is popped from the stack with the pop instruction, and it is incremented by two when an address is popped from the stack with return from subroutine ret or return from interrupt reti. bit 76543210 $3d ($5d) sp7 sp6 sp5 sp4 sp3 sp2 sp1 sp0 spl read/write r/w r/w r/w r/w r/w r/w r/w r/w initial value 0 0 0 0 0 0 0 0
18 attiny22l reset and interrupt handling the attiny22l provides two interrupt sources. these interrupts and the separate reset vector, each have a separate program vector in the program memory space. both interrupts are assigned individual enable bits which must be set (one) together with the i-bit in the status register in order to enable the interrupt. the lowest addresses in the program memory space are automatically defined as the reset and interrupt vectors. the complete list of vectors is shown in table 2 . the list also determines the priority levels of the interrupts. the lower the address the higher is the priority level. reset has the highest priority, next is int0 - the external interrupt request 0, etc. the most typical program setup for the reset and interrupt vector addresses are: reset sources the attiny22l provides three sources of reset:  power-on reset. the mcu is reset when the supply voltage is below the power-on reset threshold (v pot ).  external reset. the mcu is reset when a low level is present on the reset pin for more than 50 ns.  watchdog reset. the mcu is reset when the watchdog timer period expires and the watchdog is enabled. during reset, all i/o registers are set to their initial values, and the program starts execution from address $000. the instruction placed in address $000 must be an rjmp - relative jump - instruction to the reset handling routine. if the program never enables an interrupt source, the interrupt vectors are not used, and regular program code can be placed at these locations. the circuit diagram in figure 21 shows the reset logic. table 3 defines the timing and electrical parameters of the reset circuitry. table 2. reset and interrupt vectors vector no. program address source interrupt definition 1 $000 reset hardware pin, power-on reset and watchdog reset 2 $001 int0 external interrupt request 0 3 $002 timer0, ovf0 timer/counter0 overflow address labels code comments $000 rjmp reset ; reset handler $001 rjmp ext_int0 ; irq0 handler $002 rjmp tim_ovf0 ; timer0 overflow handler; $003 main: ldi r16, low(ramend) ; main program start out spl, r16 xxx ? ? ? ?
19 attiny22l figure 21. reset logic the attiny22l has a fixed startup time. notes: 1. the power-on reset will not work unless the supply voltage has been below v pot (falling). notes: 1. the power-on reset will not work unless the supply voltage has been below v pot (falling). power-on reset the attiny22l is designed for use in systems where it can operate from the internal rc oscillator. after v cc has reached v pot , the device will start after the time t tout (see figure 22). the start-up time t tout is one rc-oscillator cycle. the frequency of the rc oscillator is voltage dependent as shown in ? typical characteristics ? on page 44. table 3. reset characteristics (v cc = 5.0v) symbol parameter min typ max units v pot (1) power-on reset threshold voltage, rising 1.0 1.4 1.8 v power-on reset threshold voltage, falling 0.4 0.6 0.8 v v rst reset pin threshold voltage 0.6 v cc v t tout reset delay time-out period attiny22l 11 16 21 ? table 4. reset characteristics (v cc = 3.0v) symbol parameter min typ max units v pot (1) power-on reset threshold voltage, rising 1.0 1.4 1.8 v power-on reset threshold voltage, falling 0.4 0.6 0.8 v v rst reset pin threshold voltage 0.6 v cc v t tout reset delay time-out period attiny22l 22 32 42 s power-on reset circuit reset circuit watchdog timer on-chip rc-oscillator 14-stage ripple counter q0 q13 q3 q q s r internal reset por vcc reset 100 - 500k counter reset
20 attiny22l figure 22. mcu start-up, reset tied to v cc . figure 23. mcu start-up, reset controlled externally vcc reset time-out internal reset t tout v pot v rst vcc reset time-out internal reset t tout v pot v rst
21 attiny22l external reset an external reset is generated by a low level on the reset pin. reset pulses longer than 50 ns will generate a reset, even if the clock is not running. shorter pulses are not guaranteed to generate a reset. when the applied signal reaches the reset threshold voltage - v rst - on its positive edge, the delay timer starts the mcu after the time-out period t tout has expired. figure 24. external reset during operation watchdog reset when the watchdog times out, it will generate a short reset pulse of 1 clock cycle duration. on the falling edge of this pulse, the delay timer starts counting the time-out period t tout . refer to page 28 for details on operation of the watchdog. figure 25. watchdog reset during operation
22 attiny22l mcu status register - mcusr the mcu status register provides information on which reset source caused a mcu reset:  bit 7..2 - res: reserved bits these bits are reserved bits in the attiny22l and always read as zero.  bit 1 - extrf: external reset flag after a power-on reset, this bit is undefined (x). it will be set by an external reset. a watchdog reset will leave this bit unchanged.  bit 0 - porf: power-on reset flag this bit is set by a power-on reset. a watchdog reset or an external reset will leave this bit unchanged. to summarize, the following table shows the value of these two bits after the three modes of reset. to make use of these bits to identify a reset condition, the user software should clear both the porf and extrf bits as early as possible in the program. checking the porf and extrf values is done before the bits are cleared. if the bit is cleared before an external or watchdog reset occurs, the source of reset can be found by using the following truth table: interrupt handling the attiny22l has two 8-bit interrupt mask control registers; gimsk - general interrupt mask register and timsk - timer/counter interrupt mask register. when an interrupt occurs, the global interrupt enable i-bit is cleared (zero) and all interrupts are disabled. the user software can set (one) the i-bit to enable nested interrupts. the i-bit is set (one) when a return from interrupt instruction - reti - is executed. when the program counter is vectored to the actual interrupt vector in order to execute the interrupt handling routine, hard- ware clears the corresponding flag that generated the interrupt. some of the interrupt flags can also be cleared by writing a logic one to the flag bit position(s) to be cleared. if an interrupt condition occurs when the corresponding interrupt enable bit is cleared (zero), the interrupt flag will be set and remembered until the interrupt is enabled, or the flag is cleared by software. if one or more interrupt conditions occur when the global interrupt enable bit is cleared (zero), the corresponding interrupt flag(s) will be set and remembered until the global interrupt enable bit is set (one), and will be executed by order of priorit y. note that external level interrupt does not have a flag, and will only be remembered for as long as the interrupt condition is active. bit 76543210 $34 ($54)------extrfporfmcusr read/writerrrrrrr/wr/w initial value 0 0 0 0 0 0 see bit description table 5. porf and extrf values after reset reset source porf extrf power-on reset 1 undefined external reset unchanged 1 watchdog reset unchanged unchanged table 6. reset source identification porf extrf reset source 0 0 watchdog reset 0 1 external reset 10power-on reset 11power-on reset
23 attiny22l note that the status register is not automatically stored when entering an interrupt routine and restored when returning from an interrupt routine. this must be handled by software. general interrupt mask register - gimsk  bit 7 - res: reserved bit this bit is a reserved bit in the attiny22l and always reads as zero.  bit 6 - int0: external interrupt request 0 enable when the int0 bit is set (one) and the i-bit in the status register (sreg) is set (one), the external pin interrupt is enabled. the interrupt sense control0 bits 1/0 (isc01 and isc00) in the mcu general control register (mcucr) defines whether the external interrupt is activated on rising or falling edge of the int0 pin or level sensed. activity on the pin will cause a n interrupt request even if int0 is configured as an output. the corresponding interrupt of external interrupt request 0 is executed from program memory address $001. see also ? external interrupts. ?  bits 5..0 - res: reserved bits these bits are reserved bits in the attiny22l and always read as zero. general interrupt flag register - gifr  bit 7 - res: reserved bit this bit is a reserved bit in the attiny22l and always reads as zero.  bit 6 - intf0: external interrupt flag0 when an event on the int0 pin triggers an interrupt request, intf0 becomes set (one). if the i-bit in sreg and the int0 bit in gimsk are set (one), the mcu will jump to the interrupt vector at address $001. the flag is cleared when the interrupt routine is executed. alternatively, the flag can be cleared by writing a logical one to it.  bits 5..0 - res: reserved bits these bits are reserved bits in the attiny22l and always read as zero. timer/counter interrupt mask register - timsk  bit 7..2 - res: reserved bits these bits are reserved bits in the attiny22l and always read zero.  bit 1 - toie0: timer/counter0 overflow interrupt enable when the toie0 bit is set (one) and the i-bit in the status register is set (one), the timer/counter0 overflow interrupt is enabled. the corresponding interrupt (at vector $002) is executed if an overflow in timer/counter0 occurs, i.e., when the overflow flag (timer/counter0) is set (one) in the timer/counter interrupt flag register - tifr.  bit 0 - res: reserved bit this bit is a reserved bit in the attiny22l and always reads as zero. bit 7 6 5 4 3 2 1 0 $3b ($5b) - int0 - - - - - - gimsk read/write r r/w r r r r r r initial value 0 0 0 0 0 0 0 0 bit 7 6 5 4 3 2 1 0 $3a ($5a) - intf0 - - - - - - gifr read/write r r/w r r r r r r initial value 0 0 0 0 0 0 0 0 bit 7 6 5 4 3 2 1 0 $39 ($59) - - - - - - toie0 - timsk read/write r r r r r r r/w r initial value 0 0 0 0 0 0 0 0
24 attiny22l timer/counter interrupt flag register - tifr  bits 7..2 - res: reserved bits these bits are reserved bits in the attiny22l and always read zero.  bit 1 - tov0: timer/counter0 overflow flag the bit tov0 is set (one) when an overflow occurs in timer/counter0. tov0 is cleared by hardware when executing the corresponding interrupt handling vector. alternatively, tov0 is cleared by writing a logical one to the flag. when the sreg i-bit, and toie0 (timer/counter0 overflow interrupt enable), and tov0 are set (one), the timer/counter0 overflow inter- rupt is executed.  bit 0 - res: reserved bit this bit is a reserved bit in the attiny22l and always reads zero. external interrupt the external interrupt is triggered by the int0 pin. observe that, if enabled, the interrupt will trigger even if the int0 pin is configured as an output. this feature provides a way of generating a software interrupt. the external interrupt can be trig- gered by a falling or rising edge or a low level. this is set up as indicated in the specification for the mcu control register - mcucr. when the external interrupt is enabled and is configured as level triggered, the interrupt will trigger as long as the pin is held low. the external interrupt is set up as described in the specification for the mcu control register - mcucr. interrupt response time the interrupt execution response for all the enabled avr interrupts is 4 clock cycles minimum. 4 clock cycles after the interrupt flag has been set, the program vector address for the actual interrupt handling routine is executed. during these 4 clock cycles, the program counter (2 bytes) is popped back from the stack, the stack pointer is incremented by 2, and the i flag in sreg is set. the vector is a relative jump to the interrupt routine, and this jump takes 2 clock cycles. if an interr upt occurs during execution of a multi-cycle instruction, this instruction is completed before the interrupt is served. a return from an interrupt handling routine (same as for a subroutine call routine) takes 4 clock cycles. during these 4 clock cycles, the program counter (2 bytes) is popped back from the stack, and the stack pointer is incremented by 2. when the avr exits from an interrupt, it will always return to the main program and execute one more instruction before any pending interrupt is served. mcu control register - mcucr the mcu control register contains control bits for general mcu functions.  bits 7, 6 - res: reserved bits these bits are reserved bits in the attiny22l and always read as zero.  bit 5 - se: sleep enable the se bit must be set (one) to make the mcu enter the sleep mode when the sleep instruction is executed. to avoid the mcu entering the sleep mode unless it is the programmers purpose, it is recommended to set the sleep enable se bit just before the execution of the sleep instruction. bit 7 6 5 4 3 2 1 0 $38 ($58) - - - - - - tov0 - tifr read/write r r r r r r r/w r initial value 0 0 0 0 0 0 0 0 bit 76543210 $35 ($55) - - se sm - - isc01 isc00 mcucr read/write r r r/w r/w r r r/w r/w initial value 0 0 0 0 0 0 0 0
25 attiny22l  bit 4 - sm: sleep mode this bit selects between the two available sleep modes. when sm is cleared (zero), idle mode is selected as sleep mode. when sm is set (one), power down mode is selected as sleep mode. for details, refer to the section ? sleep modes ? on page 25.  bits 3, 2 - res: reserved bits these bits are reserved bits in the attiny22l, and always read as zero.  bits 1, 0 - isc01, isc00: interrupt sense control 0 bit 1 and bit 0 the external interrupt 0 is activated by the external pin int0 if the sreg i-flag and the corresponding interrupt mask is set. the level and edges on the external int0 pin that activate the interrupt are defined in table 7. the value on the int01 pin is sampled before detecting edges. if edge or toggle interrupt is selected, pulses that last longer than one clock period will generate an interrupt. shorter pulses are not guaranteed to generate an interrupt. if low level interrupt is selected, the low level must be held until the completion of the currently executing instruction to generate an interrupt. note: when changing the isc01/isc00 bits, int0 must be disabled by clearing its interrupt enable bit in the gimsk register. othe r- wise an interrupt can occur when the bits are changed. sleep modes to enter the sleep modes, the se bit in mcucr must be set (one) and a sleep instruction must be executed. if an enabled interrupt occurs while the mcu is in a sleep mode, the mcu awakes, executes the interrupt routine, and resumes execution from the instruction following sleep. the contents of the register file, sram and i/o memory are unaltered. if a reset occurs during sleep mode, the mcu wakes up and executes from the reset vector. idle mode when the sm bit is cleared (zero), the sleep instruction forces the mcu into the idle mode stopping the cpu but allowing timer/counters, watchdog and the interrupt system to continue operating. this enables the mcu to wake up from external triggered interrupts as well as internal ones like timer overflow interrupt and watchdog reset. power down mode when the sm bit is set (one), the sleep instruction forces the mcu into the power down mode. in this mode, the external oscillator is stopped, while the external interrupts and the watchdog (if enabled) continue operating. only an external reset, a watchdog reset (if enabled), or an external level interrupt on int0 can wake up the mcu. note that if a level triggered interrupt is used for wake-up from power down mode, the changed level must be held for some time to wake up the mcu. this makes the mcu less sensitive to noise. the changed level is sampled twice by the watchdog oscillator clock, and if the input has the required level during this time, the mcu will wake up. the period of the watchdog oscillator is 1 us (nominal) at 5.0v and 25c. the frequency of the watchdog oscillator is voltage dependent as shown in section ? typical characteristics ? on page 44. when waking up from power down mode, there is a delay from the wake-up condition occurs until the wake-up becomes effective. this allows the clock to restart and become stable after having been stopped. the wake-up period is equal to the clock reset period, as shown in table 3 and table 4. if the wake-up condition disappears before the mcu wakes up and starts to execute, e.g. a low level on is not held long enough, the interrupt causing the wake-up will not be executed. table 7. interrupt 0 sense control isc01 isc00 description 0 0 the low level of int0 generates an interrupt request. 01reserved 1 0 the falling edge of int0 generates an interrupt request. 1 1 the rising edge of int0 generates an interrupt request.
26 attiny22l timer/counter the attiny22l provides one general purpose 8- bit timer/counter - timer/counter0. the timer/counter has prescaling selection from the 10-bit prescaling timer. the timer/counter can either be used as a timer with an internal clock timebase or as a counter with an external pin connection that triggers the counting. timer/counter prescaler figure 26 shows the timer/counter prescaler. figure 26. timer/counter0 prescaler the four different prescaled selections are: ck/8, ck/64, ck/256 and ck/1024 where ck is the oscillator clock. ck, external source and stop, can also be selected as clock sources. 8-bit timer/counter0 figure 27 shows the block diagram for timer/counter0. the 8-bit timer/counter0 can select clock source from ck, prescaled ck, or an external pin. in addition, it can be stopped as described in the specification for the timer/counter0 control register - tccr0. the overflow status flag is found in the timer/counter interrupt flag register - tifr. control signals are found in the timer/counter0 control register - tccr0. the interrupt enable/disable settings for timer/counter0 are found in the timer/counter interrupt mask register - timsk. when timer/counter0 is externally clocked, the external signal is synchronized with the oscillator frequency of the cpu. to ensure proper sampling of the external clock, the minimum time between two external clock transitions must be at least one internal cpu clock period. the external clock signal is sampled on the rising edge of the internal cpu clock. the 8-bit timer/counter0 features both a high resolution and a high accuracy usage with the lower prescaling opportuni- ties. similarly, the high prescaling opportunities make the timer/counter0 useful for lower speed functions or exact timing functions with infrequent actions. 10-bit t/c prescaler 0 timer/counter0 clock source tck0 ck t0 cs00 cs01 cs02 ck/8 ck/256 ck/1024 ck/64
27 attiny22l figure 27. timer/counter 0 block diagram timer/counter0 control register - tccr0  bits 7..3 - res: reserved bits these bits are reserved bits in the attiny22l, and always read zero.  bits 2,1,0 - cs02, cs01, cs00: clock select0, bit 2,1 and 0 the clock select0 bits 2,1 and 0 define the prescaling source of timer0. bit 7 6 5 4 3 210 $33 ($53) - - - - - cs02 cs01 cs00 tccr0 read/write r r r r r r/w r/w r/w initial value 0 0 0 0 0 0 0 0 table 8. clock 0 prescale select cs02 cs01 cs00 description 0 0 0 stop, the timer/counter0 is stopped. 001ck 010ck/8 011ck/64 100ck/256 101ck/1024 1 1 0 external pin t0, falling edge 1 1 1 external pin t0, rising edge t0
28 attiny22l the stop condition provides a timer enable/disable function. the ck down divided modes are scaled directly from the ck oscillator clock. if the external pin modes are used for timer/counter0, transitions on pb2/(t0) will clock the counter even if the pin is configured as an output. this feature can give the user sw control of the counting. timer counter 0 - tcnt0 the timer/counter0 is realized as an up-counter with read and write access. if the timer/counter0 is written and a clock source is present, the timer/counter0 continues counting in the timer clock cycle following the write operation. watchdog timer the watchdog timer is clocked from the on-chip rc oscillator. by controlling the watchdog timer prescaler, the watchdog reset interval can be adjusted as shown in table 9. see characterization data for typical values at other v cc levels. the wdr - watchdog reset - instruction resets the watchdog timer. eight different clock cycle periods can be selected to determine the reset period. if the reset period expires without another watchdog reset, the attiny22l resets and executes from the reset vector. for timing details on the watchdog reset, refer to page 21. to prevent unintentional disabling of the watchdog, a special turn-off sequence must be followed when the watchdog is disabled. refer to the description of the watchdog timer control register for details. figure 28. watchdog timer watchdog timer control register - wdtcr  bits 7..5 - res: reserved bits these bits are reserved bits in the attiny22l and will always read as zero. bit 76543210 $32 ($52) msb lsb tcnt0 read/write r/w r/w r/w r/w r/w r/w r/w r/w initial value 0 0 0 0 0 0 0 0 bit 76543210 $21 ($41) - - - wdtoe wde wdp2 wdp1 wdp0 wdtcr read/write r r r r/w r/w r/w r/w r/w initial value 0 0 0 0 0 0 0 0 1 mhz at v cc = 5v 350 khz at v cc = 3v oscillator
29 attiny22l  bit 4 - wdtoe: watch dog turn-off enable this bit must be set (one) when the wde bit is cleared. otherwise, the watchdog will not be disabled. once set, hardware will clear this bit to zero after four clock cycles. refer to the description of the wde bit for a watchdog disable procedure.  bit 3 - wde: watch dog enable when the wde is set (one) the watchdog timer is enabled, and if the wde is cleared (zero) the watchdog timer function is disabled. wde can only be cleared if the wdtoe bit is set(one). to disable an enabled watchdog timer, the following procedure must be followed: 1. in the same operation, write a logical one to wdtoe and wde. a logical one must be written to wde even though it is set to one before the disable operation starts. 2. within the next four clock cycles, write a logical 0 to wde. this disables the watchdog.  bits 2..0 - wdp2, wdp1, wdp0: watchdog timer prescaler 1 and 0 the wdp2, wdp1 and wdp0 bits determine the watchdog timer prescaling when the watchdog timer is enabled. the different prescaling values and their corresponding time-out periods are shown in table 9. note: the frequency of the watchdog oscillator is voltage dependent as shown in the electrical characteristics section. the wdr - watchdog reset - instruction should always be executed before the watchdog timer is enabled. this ensures that the reset period will be in accordance with the watchdog timer prescale settings. if the watchdog timer is enabled without reset, the watchdog timer may not start to count from zero. table 9. watch dog timer prescale select wdp2 wdp1 wdp0 number of wdt oscillator cycles typical time-out at v cc = 3.0v typical time-out at v cc = 5.0v 0 0 0 16k cycles 47 ms 15 ms 0 0 1 32k cycles 94 ms 30 ms 0 1 0 64k cycles 0.19 s 60 ms 0 1 1 128k cycles 0.38 s 0.12 s 1 0 0 256k cycles 0.75 s 0.24 s 1 0 1 512k cycles 1.5 s 0.49 s 1 1 0 1,024k cycles 3.0 s 0.97 s 1 1 1 2,048k cycles 6.0 s 1.9 s
30 attiny22l eeprom read/write access the eeprom access registers are accessible in the i/o space. the write access time is in the range of 2.5 - 4ms, depending on the v cc voltages. a self-timing function, however, lets the user software detect when the next byte can be written. in order to prevent unintentional eeprom writes, a specific write procedure must be followed. refer to the description of the eeprom control register for details on this. when the eeprom is written, the cpu is halted for two clock cycles before the next instruction is executed. when it is read, the cpu is halted for 4 clock cycles. eeprom address register - eear  bit 7 - res: reserved bit this bit is a reserved bit in the attiny22l and will always read as zero.  bit 6..0 - eear6..0: eeprom address the eeprom address register - eear6..0 - specifies the eeprom address in the 128 bytes eeprom space. the eeprom data bytes are addressed linearly between 0 and 127. eeprom data register - eedr  bit 7..0 - eedr7..0: eeprom data for the eeprom write operation, the eedr register contains the data to be written to the eeprom in the address given by the eear register. for the eeprom read operation, the eedr contains the data read out from the eeprom at the address given by eear. eeprom control register - eecr  bit 7..3 - res: reserved bits these bits are reserved bits in the attiny22l and will always read as zero.  bit 2 - eemwe: eeprom master write enable the eemwe bit determines whether setting eewe to one causes the eeprom to be written. when eemwe is set(one) setting eewe will write data to the eeprom at the selected address. if eemwe is zero, setting eewe will have no effect. when eemwe has been set (one) by software, hardware clears the bit to zero after four clock cycles. see the description of the eewe bit for a eeprom write procedure.  bit 1 - eewe: eeprom write enable the eeprom write enable signal eewe is the write strobe to the eeprom. when address and data are correctly set up, the eewe bit must be set to write the value into the eeprom. the eemwe bit must be set when the logical one is written to eewe, otherwise no eeprom write takes place. the following procedure should be followed when writing the eeprom (the order of steps 2 and 3 is unessential): bit 76543210 $1e ($3e) - eear6 eear5 eear4 eear3 eear2 eear1 eear0 eear read/write r r/w r/w r/w r/w r/w r/w r/w initial value 0 0 0 0 0 0 0 0 bit 76543210 $1d ($3d) msb lsb eedr read/write r/w r/w r/w r/w r/w r/w r/w r/w initial value 0 0 0 0 0 0 0 0 bit 76543210 $1c ($3c) - - - - - eemwe eewe eere eecr read/writerrrrrr/wr/wr/w initial value 0 0 0 0 0 0 0 0
31 attiny22l 1. wait until eewe becomes zero 2. write new eeprom address to eear (optional) 3. write new eeprom data to eedr (optional) 4. write a logical one to the eemwe bit in eecr 5. within four clock cycles after setting eemwe, write a logical one to eewe caution: an interrupt between step 4 and step 5 will make the write cycle fail, since the eeprom master write enable will time-out. if an interrupt routine accessing the eeprom is interrupting another eeprom access, the eear and eedr reg- ister will be modified, causing the interrupted eeprom access to fail. it is recommended to have the global interrupt flag cleared during the 4 last steps to avoid these problems. when the write access time (typically 2.5 ms at v cc = 5v or 4 ms at v cc = 2.7v) has elapsed, the eewe bit is cleared (zero) by hardware. the user software can poll this bit and wait for a zero before writing the next byte. when eewe has been set, the cpu is halted for two cycles before the next instruction is executed.  bit 0 - eere: eeprom read enable the eeprom read enable signal eere is the read strobe to the eeprom. when the correct address is set up in the eear register, the eere bit must be set. when the eere bit is cleared (zero) by hardware, requested data is found in the eedr register. the eeprom read access takes one instruction and there is no need to poll the eere bit. when eere has been set, the cpu is halted for two cycles before the next instruction is executed. the user should poll the eewe bit before starting the read operation. if a write operation is in progress when new data or address is written to the eeprom i/o registers, the write operation will be interrupted, and the result is undefined. prevent eeprom corruption during periods of low v cc, the eeprom data can be corrupted because the supply voltage is too low for the cpu and the eeprom to operate properly. these issues are the same as for board level systems using the eeprom, and the same design solutions should be applied. an eeprom data corruption can be caused by two situations when the voltage is too low. first, a regular write sequence to the eeprom requires a minimum voltage to operate correctly. secondly, the cpu itself can execute instructions incorrectly, if the supply voltage for executing instructions is too low. eeprom data corruption can easily be avoided by following these design recommendations (one is sufficient): 1. keep the avr reset active (low) during periods of insufficient power supply voltage. this is best done by an exter- nal low v cc reset protection circuit, often referred to as a brown-out detector (bod). please refer to application note avr 180 for design considerations regarding power-on reset and low voltage detection. 2. keep the avr core in power down sleep mode during periods of low v cc . this will prevent the cpu from attempt- ing to decode and execute instructions, effectively protecting the eeprom registers from unintentional writes. 3. store constants in flash memory if the ability to change memory contents from software is not required. flash memory can not be updated by the cpu, and will not be subject to corruption.
32 attiny22l i/o port b all avr ports have true read-modify-write functionality when used as general digital i/o ports. this means that the direc- tion of one port pin can be changed without unintentionally changing the direction of any other pin with the sbi and cbi instructions. the same applies for changing drive value (if configured as output) or enabling/disabling of pull-up resistors (i f configured as input). port b is a 5-bit bi-directional i/o port. three i/o memory address locations are allocated for port b, one each for the data register - portb, $18 ($38), data direction register - ddrb, $17($37) and the port b input pins - pinb, $16($36). the port b input pins address is read only, while the data register and the data direction register are read/write. all port pins have individually selectable pull-up resistors. the port b output buffers can sink 20ma and thus drive led dis- plays directly. when pins pb0 to pb4 are used as inputs and are externally pulled low, they will source current if the internal pull-up resistors are activated. the port b pins with alternate functions are shown in the following table: when the pins are used for the alternate function the ddrb and portb register has to be set according to the alternate function description. port b data register - portb port b data direction register - ddrb port b input pins address - pinb the port b input pins address - pinb - is not a register, and this address enables access to the physical value on each port b pin. when reading portb, the port b data latch is read, and when reading pinb, the logical values present on the pins are read. table 10. port b pins alternate functions port pin alternate functions pb0 mosi (data input line for memory downloading) pb1 miso (data output line for memory uploading) int0 (external interrupt0 input) pb2 sck (serial clock input for serial programming) to (timer/counter0 counter clock input) bit 76543210 $18 ($38) - - - portb4 portb3 portb2 portb1 portb0 portb read/write r r r r/w r/w r/w r/w r/w initial value 0 0 0 0 0 0 0 0 bit 76543210 $17 ($37) - - - ddb4 ddb3 ddb2 ddb1 ddb0 ddrb read/write r r r r/w r/w r/w r/w r/w initial value 0 0 0 0 0 0 0 0 bit 76543210 $16 ($36) - - - pinb4 pinb3 pinb2 pinb1 pinb0 pinb read/writerrrrrrrr initial value 0 0 0 n/a n/a n/a n/a n/a
33 attiny22l general digital i/o all pins in port b have equal functionality when used as digital i/o pins. pbn, general i/o pin: the ddbn bit in the ddrb register selects the direction of this pin, if ddbn is set (one), pbn is con- figured as an output pin. if ddbn is cleared (zero), pbn is configured as an input pin. if portbn is set (one) when the pin configured as an input pin, the mos pull up resistor is activated. to switch the pull up resistor off, the portbn has to be cleared (zero) or the pin has to be configured as an output pin. the port pins are tri-stated when a reset condition becomes active, even if the clock is not running. alternate functions of port b the alternate pin functions of port b are: sck/t0 - port b, bit 2 in serial programming mode, this bit serves as the serial clock input, sck. during normal operation, this pin can serve as the external counter clock input. see the timer/counter description for further details. if external timer/counter clocking is selected, activity on this pin will clock the counter even if it is configured a s an output. miso/int0 - port b, bit 1 in serial programming mode, this bit serves as the serial data output, miso. during normal operation, this pin can serve as the external interrupt0 input. see the interrupt description for details on how to enable this interrupt. note that activity on this pin will trigger the interrupt even if the pin is configured as an output. mosi/t0 - port b, bit 0 in serial programming mode, this pin serves as the serial data input, mosi. table 11. ddbn effects on port b pins ddbn portbn i/o pull up comment 0 0 input no tri-state (hi-z) 0 1 input yes pbn will source current if ext. pulled low. 1 0 output no push-pull zero output 1 1 output no push-pull one output
attiny22l 34 memory programming program and data memory lock bits the attiny22l mcu provides two lock bits which can be left unprogrammed ( ? 1 ? ) or can be programmed ( ? 0 ? ) to obtain the additional features listed in table 12 . the lock bits can only be erased with the chip erase operation. note: 1. in the high-voltage serial programming mode, further programming of the fuse bit is also disabled. program the fuse bit before programming the lock bits. fuse bit the attiny22l has one fuse bit, spien.  when the spien fuse is programmed ( ? 0 ? ), serial program and data downloading is enabled. default value is programmed ( ? 0 ? ). this bit is not accessible in the low-voltage serial programming mode. the status of the fuse bit is not affected by chip erase. signature bytes all atmel microcontrollers have a three-byte signature code which identifies the device. the three bytes reside in a sepa- rate address space. for attiny22l (1) they are: 1. $000: $1e (indicates manufactured by atmel) 2. $001: $91 (indicates 2k bytes flash memory) 3. $002: $06 (indicates attiny22l when signature byte $001 is $91.) note: 1. when both lock bits are programmed (lock mode 3), the signature bytes can not be read in the low-voltage serial mode. reading the signature bytes will return: $00, $01 and $02. programming the flash and eeprom atmel ? s attiny22l offers 2k bytes of in-system programmable flash program memory and 128 bytes of eeprom data memory. the attiny22l is shipped with the on-chip flash program and eeprom data memory arrays in the erased state (i.e., contents = $ff) and ready to be programmed. the device supports a high-voltage (12v) serial programming mode and a low-voltage serial programming mode. the +12v is used for programming enable only, and no current of significance is drawn by this pin. the low-voltage serial programming mode provides a convenient way to download program and data into the device inside the user ? s system. the program and eeprom memory arrays in the attiny22l are programmed byte-by-byte in either programming modes. for the eeprom, an auto-erase cycle is provided within the self-timed write instruction in the low-voltage serial programming mode. during programming, the supply voltage must be in accordance with table 13. table 12. lock bit protection modes memory lock bits protection type mode lb1 lb2 1 1 1 no memory lock features enabled. 2 0 1 further programming of the flash and eeprom is disabled. (1) 3 0 0 same as mode 2, and verify is also disabled.
attiny22l 35 table 13. supply voltage during programming high-voltage serial programming this section describes how to program and verify flash program memory, eeprom data memory, lock bits and fuse bit in the attiny22l. figure 29. high-voltage serial programming high-voltage serial programming algorithm to program and verify the attiny22l in the high-voltage serial programming mode, the following sequence is recommended (see instruction formats in table 14): 1. power-up sequence: apply 4.5 - 5.5v between v cc and gnd. set reset and pb0 to ? 0 ? and wait at least 100 ns. set pb3 to ? 0 ? . wait at least 4s. apply 12v to reset and wait at least 100 ns before changing pb0. wait 8 s before giving any instructions. 2. the flash array is programmed one byte at a time by supplying first the address, then the low and high data byte. the write instruction is self-timed, wait until the pb2 (rdy/bsy ) pin goes high. 3. the eeprom array is programmed one byte at a time by supplying first the address, then the data byte. the write instruction is self-timed, wait until the pb2 (rdy/bsy ) pin goes high. 4. any memory location can be verified by using the read instruction which returns the contents at the selected address at serial output pb2. 5. power-off sequence:set pb3 to ? 0 ? . set reset to ? 0 ? . tu r n v cc power off. when writing or reading serial data to the device, data is clocked on the rising edge of the serial clock, see figure 30, fig- ure 31 and table 15 for details. part low-voltage serial programming high-voltage serial programming attiny22l 2.7 - 6.0v 4.5 - 5.5v reset pb3 gnd vcc pb2 pb1 pb0 serial data output serial instr. input serial data input serial clock input 11.5 - 12.5v 4.5 - 5.5v attiny22l
attiny22l 36 figure 30. high-voltage serial programming waveforms table 14. high-voltage serial programming instruction set instruction instruction format operation remarks instr.1 instr.2 instr.3 instr.4 chip erase pb0 pb1 pb2 0_1000_0000_00 0_0100_1100_00 x_xxxx_xxxx_xx 0_0000_0000_00 0_0110_0100_00 x_xxxx_xxxx_xx 0_0000_0000_00 0_0110_1100_00 x_xxxx_xxxx_xx 0_0000_0000_00 0_0100_1100_00 x_xxxx_xxxx_xx wait t wlwh_ce after instr.3 for the chip erase cycle to finish. write flash high and low address pb0 pb1 pb2 0_0001_0000_00 0_0100_1100_00 x_xxxx_xxxx_xx 0_0000_00 aa _00 0_0001_1100_00 x_xxxx_xxxx_xx 0_ bbbb _ bbbb _00 0_0000_1100_00 x_xxxx_xxxx_xx repeat instr.2 for a new 256 byte page. repeat instr.3 for each new address. write flash low byte pb0 pb1 pb2 0_ i i i i _ i i i i _00 0_0010_1100_00 x_xxxx_xxxx_xx 0_0000_0000_00 0_0110_0100_00 x_xxxx_xxxx_xx 0_0000_0000_00 0_0110_1100_00 0_0000_0000_00 wait after instr.3 until pb2 goes high. repeat instr.1, instr. 2 and instr.3 for each new address. write flash high byte pb0 pb1 pb2 0_ i i i i _ i i i i _00 0_0010_1100_00 x_xxxx_xxxx_xx 0_0000_0000_00 0_0111_0100_00 x_xxxx_xxxx_xx 0_0000_0000_00 0_0111_1100_00 0_0000_0000_00 wait after instr.3 until pb2 goes high. repeat instr.1, instr. 2 and instr.3 for each new address. read flash high and low address pb0 pb1 pb2 0_0000_0010_00 0_0100_1100_00 x_xxxx_xxxx_xx 0_0000_00 aa _00 0_0001_1100_00 x_xxxx_xxxx_xx 0_ bbbb _ bbbb _00 0_0000_1100_00 x_xxxx_xxxx_xx repeat instr.2 and instr.3 for each new address. read flash low byte pb0 pb1 pb2 0_0000_0000_00 0_0110_1000_00 x_xxxx_xxxx_xx 0_0000_0000_00 0_0110_1100_00 o _ oooo _ ooo x_xx repeat instr.1 and instr.2 for each new address. read flash high byte pb0 pb1 pb2 0_0000_0000_00 0_0111_1000_00 x_xxxx_xxxx_xx 0_0000_0000_00 0_0111_1100_00 o _ oooo _ ooo x_xx repeat instr.1 and instr.2 for each new address. write eeprom low address pb0 pb1 pb2 0_0001_0001_00 0_0100_1100_00 x_xxxx_xxxx_xx 0_0 bbb _ bbbb _00 0_0000_1100_00 x_xxxx_xxxx_xx repeat instr.2 for each new address. write eeprom byte pb0 pb1 pb2 0_ i i i i _ i i i i _00 0_0010_1100_00 x_xxxx_xxxx_xx 0_0000_0000_00 0_0110_0100_00 x_xxxx_xxxx_xx 0_0000_0000_00 0_0110_1100_00 0_0000_0000_00 wait after instr.3 until pb2 goes high read eeprom low address pb0 pb1 pb2 0_0000_0011_00 0_0100_1100_00 x_xxxx_xxxx_xx 0_0 bbb _ bbbb _00 0_0000_1100_00 x_xxxx_xxxx_xx repeat instr.2 for each new address. msb msb msb lsb lsb lsb 012345678910 serial data input pb0 serial instr. input pb1 serial data output pb2 serial clock input pb3
attiny22l 37 note: a = address high bits b = address low bits i = data in o = data out x = don ? t care 1 = lock bit1 2 = lock bit2 s = spien fuse high-voltage serial programming characteristics figure 31. high-voltage serial programming timing read eeprom byte pb0 pb1 pb2 0_0000_0000_00 0_0110_1000_00 x_xxxx_xxxx_xx 0_0000_0000_00 0_0110_1100_00 o _ oooo _ ooo x_xx repeat instr.2 for each new address write fuse bit pb0 pb1 pb2 0_0100_0000_00 0_0100_1100_00 x_xxxx_xxxx_xx 0_11 s 1_1110_00 0_0010_1100_00 x_xxxx_xxxx_xx 0_0000_0000_00 0_0110_0100_00 x_xxxx_xxxx_xx 0_0000_0000_00 0_0110_1100_00 x_xxxx_xxxx_xx wait t wlwh_pfb after instr.3 for the write fuse bit cycle to finish. set s = ? 0 ? to program, ? 1 ? to unprogram. write lock bits pb0 pb1 pb2 0_0010_0000_00 0_0100_1100_00 x_xxxx_xxxx_xx 0_1111_1 21 1_00 0_0010_1100_00 x_xxxx_xxxx_xx 0_0000_0000_00 0_0110_0100_00 x_xxxx_xxxx_xx 0_0000_0000_00 0_0110_1100_00 0_0000_0000_00 wait after instr.4 until pb2 goes high. write 2 , 1 = ? 0 ? to program the lock bit. read fuse and lock bits pb0 pb1 pb2 0_0000_0100_00 0_0100_1100_00 x_xxxx_xxxx_xx 0_0000_0000_00 0_0111_1000_00 x_xxxx_xxxx_xx 0_0000_0000_00 0_0111_1100_00 1 _ 2 s xx_xx0x_xx reading 1 , 2 , s = ? 0 ? means the fuse/lock bit is programmed. read signature bytes pb0 pb1 pb2 0_0000_1000_00 0_0100_1100_00 x_xxxx_xxxx_xx 0_0000_00 bb _00 0_0000_1100_00 x_xxxx_xxxx_xx 0_0000_0000_00 0_0110_1000_00 x_xxxx_xxxx_xx 0_0000_0000_00 0_0110_1100_00 o _ oooo _ ooo x_xx repeat instr.2 - instr.4 for each signature byte address table 14. high-voltage serial programming instruction set (continued) instruction instruction format operation remarks instr.1 instr.2 instr.3 instr.4 sdi (pb0), sii (pb1) sdo (pb2) sci (pb3) t ivsh t shsl t slsh t shix t shov
attiny22l 38 low-voltage serial downloading both the program and data memory arrays can be programmed using the serial spi bus while reset is pulled to gnd. the serial interface consists of pins sck, mosi (input) and miso (output), see figure 32. after reset is set low, the programming enable instruction needs to be executed first before program/erase instructions can be executed. figure 32. low-voltage serial programming and verify for the eeprom, an auto-erase cycle is provided within the self-timed write instruction and there is no need to first exe- cute the chip erase instruction. the chip erase instruction turns the content of every memory location in both the program and eeprom arrays into $ff. the program and eeprom memory arrays have separate address spaces, $0000 to $03ff for flash program memory and $000 to $07f for eeprom data memory. the device is clocked from the internal rc-oscillator. the minimum low and high periods for the serial clock (sck) input are defined as follows: low: > 2 mcu clock cycles high: > 2 mcu clock cycles table 15. high-voltage serial programming characteristics t a = 25 c ?10%, v cc = 5.0v ?10% (unless otherwise noted) symbol parameter min typ max units t shsl sci (pb3) pulse width high 100 ns t slsh sci (pb3) pulse width low 100 ns t ivsh sdi (pb0), sii (pb1) valid to sci (pb3) high 50 ns t shix sdi (pb0), sii (pb1) hold after sci (pb3) high 50 ns t shov sci (pb3) high to sdo (pb2) valid 10 16 32 ns t wlwh_ce wait after instr.3 for chip erase 5 10 15 ms t wlwh_pfb wait after instr.3 for write fuse bit 1.0 1.5 1.8 ms reset gnd vcc pb2 pb1 pb0 sck miso mosi 2.7 - 6.0v attiny22/l gnd
attiny22l 39 low-voltage serial programming algorithm when writing serial data to the attiny22l, data is clocked on the rising edge of sck. when reading data from the attiny22l, data is clocked on the falling edge of sck. see figure 33, figure 34 and table 18 for timing details. to program and verify the attiny22l in the low-voltage serial programming mode, the following sequence is recom- mended (see four byte instruction formats in table 17 ): 1. power-up sequence: apply power between v cc and gnd while reset and sck are set to ? 0 ? (if the programmer can not guarantee that sck is held low during power-up, reset must be given a positive pulse after sck has been set to ? 0 ? ). 2. wait for at least 20 ms and enable serial programming by sending the programming enable serial instruction to the mosi (pb0) pin. refer to the above section for minimum low and high periods for the serial clock input, sck. 3. the serial programming instructions will not work if the communication is out of synchronization. when in sync, the second byte ($53) will echo back when issuing the third byte of the programming enable instruction. whether the echo is correct or not, all 4 bytes of the instruction must be transmitted. if the $53 did not echo back, give sck a positive pulse and issue a new programming enable instruction. if the $53 is not seen within 32 attempts, there is no functional device connected. 4. if a chip erase is performed (must be done to erase the flash), wait t wd_erase after the instruction, give reset a positive pulse, and start over from step 2. see table 19 on page 42 for t wd_erase value. 5. the flash or eeprom array is programmed one byte at a time by supplying the address and data together with the appropriate write instruction. an eeprom memory location is first automatically erased before new data is written. use data polling to detect when the next byte in the flash or eeprom can be written. if polling is not used, wait t wd_prog before transmitting the next instruction. see table 20 on page 42 for t wd_prog value. in an erased device, no $ffs in the data file(s) needs to be programmed. 6. any memory location can be verified by using the read instruction which returns the content at the selected address at the serial output miso (pb1) pin. 7. at the end of the programming session, reset can be set high to commence normal operation. 8. power-off sequence (if needed): set reset to ? 0 ? . turn v cc power off.
attiny22l 40 data polling eeprom when a byte is being programmed into the eeprom, reading the address location being programmed will give the value p1 until the auto-erase is finished, and then the value p2. see table 16 for p1 and p2 values. at the time the device is ready for a new eeprom byte, the programmed value will read correctly. this is used to deter- mine when the next byte can be written. this will not work for the values p1 and p2, so when programming these values, the user will have to wait for at least the prescribed time t wd_prog before programming the next byte. see table 19 for t wd_prog value. as a chip-erased device contains $ff in all locations, programming of addresses that are meant to contain $ff, can be skipped. this does not apply if the eeprom is reprogrammed without first chip-erasing the device. data polling flash when a byte is being programmed into the flash, reading the address location being programmed will give the value $ff. at the time the device is ready for a new byte, the programmed value will read correctly. this is used to determine when the next byte can be written. this will not work for the value $ff, so when programming this value, the user will have to wait for at least t wd_prog before programming the next byte. as a chip-erased device contains $ff in all locations, programming of addresses that are meant to contain $ff, can be skipped. figure 33. low-voltage serial downloading waveforms table 16. read back value during eeprom polling part p1 p2 attiny22l $00 $ff msb msb lsb lsb serial clock input pb2(sck) serial data input pb0(mosi) serial data output pb1(miso)
attiny22l 41 note: a = address high bits b = address low bits h = 0 - low byte, 1- high byte o = data out i = data in x = don ? t care 1 = lock bit 1 2 = lock bit 2 s = spien fuse notes: 1. the signature bytes are not readable in lock mode 3, i.e. both lock bits programmed. table 17. low-voltage serial programming instruction set attiny22l instruction instruction format operation byte 1 byte 2 byte 3 byte 4 programming enable 1010 1100 0101 0011 xxxx xxxx xxxx xxxx enable serial programming while reset is low. chip erase 1010 1100 100x xxxx xxxx xxxx xxxx xxxx chip erase both flash and eeprom memory arrays. read program memory 0010 h 000 0000 00 aa bbbb bbbb oooo oooo read h (high or low) data o from program memory at word address a : b . write program memory 0100 h 000 0000 00 aa bbbb bbbb iiii iiii write h (high or low) data i to program memory at word address a : b . read eeprom memory 1010 0000 0000 0000 x bbb bbbb oooo oooo read data o from eeprom memory at address b . write eeprom memory 1100 0000 0000 0000 x bbb bbbb iiii iiii write data i to eeprom memory at address b . read lock and fuse bit 0101 1000 xxxx xxxx xxxx xxxx 12 s x xxx0 read lock and fuse bit. ? 0 ? = programmed, ? 1 ? = unprogrammed. write lock bits 1010 1100 1111 1 21 1 xxxx xxxx xxxx xxxx write lock bits. set bits 1 , 2 = ? 0 ? to program lock bits. read signature bytes 0011 0000 xxxx xxxx xxxx xx bb oooo oooo read signature byte o from address b (1)
attiny22l 42 low-voltage serial programming characteristics figure 34. low-voltage serial programming timing table 18. low-voltage serial programming characteristics t a = -40 c to 85 c, v cc = 2.7 - 6.0v (unless otherwise noted) the period of the internal rc oscillator - t clcl is voltage dependend as shown in ? typical characteristics ? on page 44. symbol parameter min typ max units t shsl sck pulse width high 2 t clcl ns t slsh sck pulse width low 2 t clcl ns t ovsh mosi setup to sck high t clcl ns t shox mosi hold after sck high 2 t clcl ns t sliv sck low to miso valid 10 16 32 ns table 19. minimum wait delay after the chip erase instruction symbol 3.2v 3.6v 4.0v 5.0v units t wd_erase 18 14 12 8 ms table 20. minimum wait delay after writing a flash or eeprom location symbol 3.2v 3.6v 4.0v 5.0v units t wd_prog 9764 ms mosi miso sck t ovsh t shsl t slsh t shox t sliv
attiny22l 43 electrical characteristics absolute maximum ratings* dc characteristics t a = -40 c to 85 c, v cc = 2.7v to 6.0v (unless otherwise noted) notes: 1. ? max ? means the highest value where the pin is guaranteed to be read as low 2. ? min ? means the lowest value where the pin is guaranteed to be read as high 3. minimum v cc for power down is 2v. operating temperature.................................. -55 c to +125 c *notice: stresses beyond those listed under ? absolute maximum ratings ? may cause permanent dam- age to the device. this is a stress rating only and functional operation of the device at these or other conditions beyond those indicated in the operational sections of this specification is not implied. exposure to absolute maximum rating conditions for extended periods may affect device reliability. storage temperature ..................................... -65 c to +150 c voltage on any pin except reset with respect to ground ................................-1.0v to v cc +0.5v voltage on reset with respect to ground......-1.0v to +13.0v maximum operating voltage ............................................ 6.6v dc current per i/o pin ............................................... 40.0 ma dc current v cc and gnd pins................................ 200.0 ma symbol parameter condition min typ max units v il input low voltage -0.5 0.3 v cc (1) v v ih input high voltage (except reset )0.6 v cc (2) v cc + 0.5 v v ih2 input high voltage reset 0.85 v cc (2) v cc + 0.5 v v ol output low voltage ports b i ol = 20 ma, v cc = 5v i ol = 10 ma, v cc = 3v 0.5 0.4 v v v oh output high voltage ports b i oh = -3 ma, v cc = 5v i oh = -1.5 ma, v cc = 3v 4.2 2.4 v v i il input leakage current i/o pin v cc = 6v, pin low (absolute value) 8.0 a i ih input leakage current i/o pin v cc = 6v, pin high (absolute value) 8.0 a rrst reset pullup 100 500 k ? r i/o i/o pin pullup 30 150 k ? i cc power supply current active, v cc = 3v 1.5 ma idle, v cc = 3v 100 a power down, v cc = 3v wdt enabled 25.0 a power down, v cc = 3v wdt disabled 20.0 a
attiny22l 44 typical characteristics the following charts show typical behavior. these figures are not tested during manufacturing. all current consumption measurements are performed with all i/o pins configured as inputs and with internal pull-ups enabled. the current consumption is a function of several factors such as: operating voltage, operating frequency, loading of i/o pins, switching rate of i/o pins, code executed and ambient temperature. the dominating factor is the operating voltage, as the frequency of attiny22l is also a function of the operationg voltage. the current drawn from capacitive loaded pins may be estimated (for one pin) as c l x v cc x f where c l = load capacitance, v cc = operating voltage and f = average switching frequency of i/o pin. figure 35. active supply current vs. v cc active supply current vs. v cc i cc (ma) v cc (v) 0 1 2 3 4 5 6 7 2 2.5 3 3.5 4 4.5 5 5.5 6 t = 25 ? c a t = 85 ? c a
attiny22l 45 figure 36. idle supply current vs. v cc figure 37. power down supply current vs. v cc 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 2 2.5 3 3.5 4 4.5 5 5.5 6 t = 25 ? c a t = 85 ? c a idle supply current vs. v cc i cc (ma) v cc (v) t = 85 ? c a t = 25 ? c a power down supply current vs. v cc i cc (?) v cc (v) watchdog timer disabled t = 45 ? c a t = 70 ? c a 0 5 10 15 20 25 2 2.5 3 3.5 4 4.5 5 5.5 6
attiny22l 46 figure 38. power down supply current vs. v cc figure 39. oscillator frequency vs. v cc note: the frequency of the rc-oscillator may be 10% off the typical value for a given temperature and v cc . 0 20 40 60 80 100 120 140 160 180 2 2.5 3 3.5 4 4.5 5 5.5 6 t = 85 ? c a power down supply current vs. v cc i cc (?) v cc (v) watchdog timer enabled t = 25 ? c a 0 200 400 600 800 1000 1200 1400 1600 2 2.5 3 3.5 4 4.5 5 5.5 6 t = 85 ? c a t = 25 ? c a rc oscillator frequency vs. v cc v (v) cc f (khz) rc
attiny22l 47 sink and source capabilities of i/o ports are measured on one pin at a time. figure 40. pull-up resistor current vs. input voltage figure 41. pull-up resistor current vs. input voltage 0 20 40 60 80 100 120 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 pull-up resistor current vs. input voltage v = 5v cc i ( a) op v (v) op t = 85 ? c a t = 25 ? c a 0 5 10 15 20 25 30 0 0.5 1 1.5 2 2.5 3 pull-up resistor current vs. input voltage i ( a) op v (v) op v = 2.7v cc t = 85 ? c a t = 25 ? c a
attiny22l 48 figure 42. i/o pin sink current vs. output voltage figure 43. i/o pin source current vs. output voltage 0 10 20 30 40 50 60 70 0 0.5 1 1.5 2 2.5 3 v = 5v cc i (ma) ol v (v) ol t = 85 ? c a t = 25 ? c a i/o pin sink current vs. output voltage 0 2 4 6 8 10 12 14 16 18 20 0 0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 i/o pin source current vs. output voltage v = 5v cc i (ma) oh v (v) oh t = 85 ? c a t = 25 ? c a
attiny22l 49 figure 44. i/o pin sink current vs. output voltage figure 45. i/o pin source current vs. output voltage 0 5 10 15 20 25 0 0.5 1 1.5 2 i (ma) ol v (v) ol t = 85 ? c a t = 25 ? c a i/o pin sink current vs. output voltage v = 2.7v cc 0 1 2 3 4 5 6 0 0.5 1 1.5 2 2.5 3 i/o pin source current vs. output voltage i (ma) oh v (v) oh t = 85 ? c a t = 25 ? c a v = 2.7v cc
attiny22l 50 figure 46. i/o pin input threshold voltage vs. v cc figure 47. i/o pin input hysteresis vs. v cc 0 0.5 1 1.5 2 2.5 2.7 4.0 5.0 threshold voltage (v) v cc i/o pin input threshold voltage vs. v cc t = 25 ? c a 0 0.02 0.04 0.06 0.08 0.1 0.12 0.14 0.16 0.18 2.7 4.0 5.0 input hysteresis (v) v cc i/o pin input hysteresis vs. v cc t = 25 ? c a
attiny22l 51 notes: 1. for compatibility with future devices, reserved bits should be written to zero if accessed. reserved i/o memory address es should never be written. 2. some of the status flags are cleared by writing a logical one to them. note that the cbi and sbi instructions will operate on all bits in the i/o register, writing a one back into any flag read as set, thus clearing the flag. the cbi and sbi instruction s work with registers $00 to $1f only. register summary address name bit 7 bit 6 bit 5 bit 4 bit 3 bit 2 bit 1 bit 0 page $3f ($5f) sreg i t h s v n z c page 16 $3e ($5e) reserved $3d ($5d) spl sp7 sp6 sp5 sp4 sp3 sp2 sp1 sp0 page 17 $3c ($5c) reserved $3b ($5b) gimsk -int0 - - - - - - page 23 $3a ($5a) gifr -intf0 page 23 $39 ($59) timsk - - - - - -toie0 - page 23 $38 ($58) tifr - - - - - -tov0 - page 24 $37 ($57) reserved $36 ($56) reserved $35 ($55) mcucr - -sesm - - isc01 isc00 page 24 $34 ($54) mcusr - - - - - - extrf porf page 22 $33 ($53) tccr0 - - - - - cs02 cs01 cs00 page 27 $32 ($52) tcnt0 timer/counter0 (8 bit) page 28 $31 ($51) reserved $30 ($50) reserved $2f ($4f) reserved $2e ($4e) reserved $2d ($4d) reserved $2c ($4c) reserved $2b ($4b) reserved $2a ($4a) reserved $29 ($49) reserved $28 ($48) reserved $27 ($47) reserved $26 ($46) reserved $25 ($45) reserved $24 ($44) reserved $23 ($43) reserved $22 ($42) reserved $21 ($41) wdtcr - - - wdtoe wde wdp2 wdp1 wdp0 page 28 $20 ($40) reserved $1f ($3f) reserved $1e ($3e) eear - eeprom address register page 30 $1d ($3d) eedr eeprom data register page 30 $1c ($3c) eecr - - - - - eemw eewe eere page 30 $1b ($3b) reserved $1a ($3a) reserved $19 ($39) reserved $18 ($38) portb - - - portb portb portb portb portb page 32 $17 ($37) ddrb - - - ddb4 ddb3 ddb2 ddb1 ddb0 page 32 $16 ($36) pinb - - - pinb4 pinb3 pinb2 pinb1 pinb0 page 32 $15 ($35) reserved reserved $00 ($20) reserved
attiny22l 52 instruction set summary mnemonics operands description operation flags #clock arithmetic and logic instructions add rd, rr add two registers rd rd + rr z,c,n,v,h 1 adc rd, rr add with carry two registers rd rd + rr + c z,c,n,v,h 1 adiw rdl,k add immediate to word rdh:rdl rdh:rdl + k z,c,n,v,s 2 sub rd, rr subtract two registers rd rd ? rr z,c,n,v,h 1 subi rd, k subtract constant from register rd rd ? k z,c,n,v,h 1 sbiw rdl,k subtract immediate from word rdh:rdl rdh:rdl ? k z,c,n,v,s 2 sbc rd, rr subtract with carry two registers rd rd ? rr ? c z,c,n,v,h 1 sbci rd, k subtract with carry constant from reg. rd rd ? k ? c z,c,n,v,h 1 and rd, rr logical and registers rd rd ? rr z,n,v 1 andi rd, k logical and register and constant rd rd ? k z,n,v 1 or rd, rr logical or registers rd rd v rr z,n,v 1 ori rd, k logical or register and constant rd rd v k z,n,v 1 eor rd, rr exclusive or registers rd rd rr z,n,v 1 com rd one s complement rd $ff ? rd z,c,n,v 1 neg rd two s complement rd $00 ? rd z,c,n,v,h 1 sbr rd,k set bit(s) in register rd rd v k z,n,v 1 cbr rd,k clear bit(s) in register rd rd ? ($ff ? k) z,n,v 1 inc rd increment rd rd + 1 z,n,v 1 dec rd decrement rd rd ? 1 z,n,v 1 tst rd test for zero or minus rd rd ? rd z,n,v 1 clr rd clear register rd rd rd z,n,v 1 ser rd set register rd $ff none 1 branch instructions rjmp k relative jump pc pc + k + 1 none 2 ijmp indirect jump to (z) pc z none 2 rcall k relative subroutine call pc pc + k + 1 none 3 icall indirect call to (z) pc z none 3 ret subroutine return pc stack none 4 reti interrupt return pc stack i 4 cpse rd,rr compare, skip if equal if (rd = rr) pc pc + 2 or 3 none 1 / 2 / 3 cp rd,rr compare rd ? rr z, n,v,c,h 1 cpc rd,rr compare with carry rd ? rr ? c z, n,v,c,h 1 cpi rd,k compare register with immediate rd ? k z, n,v,c,h 1 sbrc rr, b skip if bit in register cleared if (rr(b)=0) pc pc + 2 or 3 none 1 / 2 / 3 sbrs rr, b skip if bit in register is set if (rr(b)=1) pc pc + 2 or 3 none 1 / 2 / 3 sbic p, b skip if bit in i/o register cleared if (p(b)=0) pc pc + 2 or 3 none 1 / 2 / 3 sbis p, b skip if bit in i/o register is set if (r(b)=1) pc pc + 2 or 3 none 1 / 2 / 3 brbs s, k branch if status flag set if (sreg(s) = 1) then pc pc + k + 1 none 1 / 2 brbc s, k branch if status flag cleared if (sreg(s) = 0) then pc pc + k + 1 none 1 / 2 breq k branch if equal if (z = 1) then pc pc + k + 1 none 1 / 2 brne k branch if not equal if (z = 0) then pc pc + k + 1 none 1 / 2 brcs k branch if carry set if (c = 1) then pc pc + k + 1 none 1 / 2 brcc k branch if carry cleared if (c = 0) then pc pc + k + 1 none 1 / 2 brsh k branch if same or higher if (c = 0) then pc pc + k + 1 none 1 / 2 brlo k branch if lower if (c = 1) then pc pc + k + 1 none 1 / 2 brmi k branch if minus if (n = 1) then pc pc + k + 1 none 1 / 2 brpl k branch if plus if (n = 0) then pc pc + k + 1 none 1 / 2 brge k branch if greater or equal, signed if (n v= 0) then pc pc + k + 1 none 1 / 2 brlt k branch if less than zero, signed if (n v= 1) then pc pc + k + 1 none 1 / 2 brhs k branch if half carry flag set if (h = 1) then pc pc + k + 1 none 1 / 2 brhc k branch if half carry flag cleared if (h = 0) then pc pc + k + 1 none 1 / 2 brts k branch if t flag set if (t = 1) then pc pc + k + 1 none 1 / 2 brtc k branch if t flag cleared if (t = 0) then pc pc + k + 1 none 1 / 2 brvs k branch if overflow flag is set if (v = 1) then pc pc + k + 1 none 1 / 2 brvc k branch if overflow flag is cleared if (v = 0) then pc pc + k + 1 none 1 / 2 brie k branch if interrupt enabled if (i = 1) then pc pc + k + 1 none 1 / 2 brid k branch if interrupt disabled if (i = 0) then pc pc + k + 1 none 1 / 2
attiny22l 53 data transfer instructions mov rd, rr move between registers rd rr none 1 ldi rd, k load immediate rd k none 1 ld rd, x load indirect rd (x) none 2 ld rd, x+ load indirect and post-inc. rd (x), x x + 1 none 2 ld rd, - x load indirect and pre-dec. x x ? 1, rd (x) none 2 ld rd, y load indirect rd (y) none 2 ld rd, y+ load indirect and post-inc. rd (y), y y + 1 none 2 ld rd, - y load indirect and pre-dec. y y ? 1, rd (y) none 2 ldd rd,y+q load indirect with displacement rd (y + q) none 2 ld rd, z load indirect rd (z) none 2 ld rd, z+ load indirect and post-inc. rd (z), z z+1 none 2 ld rd, -z load indirect and pre-dec. z z - 1, rd (z) none 2 ldd rd, z+q load indirect with displacement rd (z + q) none 2 lds rd, k load direct from sram rd (k) none 2 st x, rr store indirect (x) rr none 2 st x+, rr store indirect and post-inc. (x) rr, x x + 1 none 2 st - x, rr store indirect and pre-dec. x x - 1, (x) rr none 2 st y, rr store indirect (y) rr none 2 st y+, rr store indirect and post-inc. (y) rr, y y + 1 none 2 st - y, rr store indirect and pre-dec. y y - 1, (y) rr none 2 std y+q,rr store indirect with displacement (y + q) rr none 2 st z, rr store indirect (z) rr none 2 st z+, rr store indirect and post-inc. (z) rr, z z + 1 none 2 st -z, rr store indirect and pre-dec. z z - 1, (z) rr none 2 std z+q,rr store indirect with displacement (z + q) rr none 2 sts k, rr store direct to sram (k) rr none 2 lpm load program memory r0 (z) none 3 in rd, p in port rd p none 1 out p, rr out port p rr none 1 push rr push register on stack stack rr none 2 pop rd pop register from stack rd stack none 2 bit and bit-test instructions sbi p,b set bit in i/o register i/o(p,b) 1 none 2 cbi p,b clear bit in i/o register i/o(p,b) 0 none 2 lsl rd logical shift left rd(n+1) rd(n), rd(0) 0 z,c,n,v 1 lsr rd logical shift right rd(n) rd(n+1), rd(7) 0 z,c,n,v 1 rol rd rotate left through carry rd(0) c,rd(n+1) rd(n),c rd(7) z,c,n,v 1 ror rd rotate right through carry rd(7) c,rd(n) rd(n+1),c rd(0) z,c,n,v 1 asr rd arithmetic shift right rd(n) rd(n+1), n=0..6 z,c,n,v 1 swap rd swap nibbles rd(3..0) rd(7..4),rd(7..4) rd(3..0) none 1 bset s flag set sreg(s) 1 sreg(s) 1 bclr s flag clear sreg(s) 0 sreg(s) 1 bst rr, b bit store from register to t t rr(b) t 1 bld rd, b bit load from t to register rd(b) t none 1 sec set carry c 1c1 clc clear carry c 0 c 1 sen set negative flag n 1n1 cln clear negative flag n 0 n 1 sez set zero flag z 1z1 clz clear zero flag z 0 z 1 sei global interrupt enable i 1i1 cli global interrupt disable i 0 i 1 ses set signed test flag s 1s1 cls clear signed test flag s 0 s 1 sev set twos complement overflow v 1v1 clv clear twos complement overflow v 0 v 1 set set t in sreg t 1t1 clt clear t in sreg t 0 t 1 seh set half carry flag in sreg h 1h1 clh clear half carry flag in sreg h 0 h 1 nop no operation none 1 sleep sleep (see specific descr. for sleep none 3 wdr watchdog reset (see specific descr. for wdr/timer) none 1 instruction set summary (continued) mnemonics operands description operation flags #clock
attiny22l 54 ordering information power supply speed (mhz) ordering code package operation range 2.7 - 6.0v internal osc ~1mhz@5.0v attiny22l-1pc attiny22l-1sc 8p3 8s2 commercial (0 c to 70 c) attiny22l-1pi ATTINY22L-1SI 8p3 8s2 industrial (-40 c to 85 c) package type 8p3 8-pin, 0.300" wide, plastic dual inline package (pdip) 8s2 8-lead, 0.200" wide, plastic gull-wing small outline (eiaj soic)
attiny22l 55 packaging information .400 (10.16) .355 (9.02) pin 1 .280 (7.11) .240 (6.10) .037 (.940) .027 (.690) .300 (7.62) ref .210 (5.33) max seating plane .100 (2.54) bsc .015 (.380) min .022 (.559) .014 (.356) .150 (3.81) .115 (2.92) .070 (1.78) .045 (1.14) .325 (8.26) .300 (7.62) 0 15 ref .430 (10.9) max .012 (.305) .008 (.203) .020 (.508) .012 (.305) .213 (5.41) .205 (5.21) .330 (8.38) .300 (7.62) pin 1 .050 (1.27) bsc .212 (5.38) .203 (5.16) .080 (2.03) .070 (1.78) .013 (.330) .004 (.102) 0 8 ref .010 (.254) .007 (.178) .035 (.889) .020 (.508) 8p3, 8-pin, 0.300" wide, plastic dual inline package (pdip) dimensions in inches and (millimeters) jedec standard ms-001 ba 8s2, 8-lead, 0.200" wide, plastic gull wing small outline (eiaj soic) dimensions in inches and (millimeters)
? atmel corporation 2000. atmel corporation makes no warranty for the use of its products, other than those expressly contained in the company s standard war- ranty which is detailed in atmel s terms and conditions located on the company s web site. the company assumes no responsibility for any errors which may appear in this document, reserves the right to change devices or specifications detailed herein at any tim e without notice, and does not make any commitment to update the information contained herein. no licenses to patents or other intellectu al prop- erty of atmel are granted by the company in connection with the sale of atmel products, expressly or by implication. atmel s products are not authorized for use as critical components in life support devices or systems. atmel headquarters atmel operations corporate headquarters 2325 orchard parkway san jose, ca 95131 tel (408) 441-0311 fax (408) 487-2600 europe atmel u.k., ltd. coliseum business centre riverside way camberley, surrey gu15 3yl england tel (44) 1276-686-677 fax (44) 1276-686-697 asia atmel asia, ltd. room 1219 chinachem golden plaza 77 mody road tsimhatsui east kowloon hong kong tel (852) 2721-9778 fax (852) 2722-1369 japan atmel japan k.k. 9f, tonetsu shinkawa bldg. 1-24-8 shinkawa chuo-ku, tokyo 104-0033 japan tel (81) 3-3523-3551 fax (81) 3-3523-7581 atmel colorado springs 1150 e. cheyenne mtn. blvd. colorado springs, co 80906 tel (719) 576-3300 fax (719) 540-1759 atmel rousset zone industrielle 13106 rousset cedex france tel (33) 4-4253-6000 fax (33) 4-4253-6001 fax-on-demand north america: 1-(800) 292-8635 international: 1-(408) 441-0732 e-mail literature@atmel.com web site http://www.atmel.com bbs 1-(408) 436-4309 printed on recycled paper. 1273b 02/00/xm marks bearing and/or are registered trademarks and trademarks of atmel corporation. terms and product names in this document may be trademarks of others.


▲Up To Search▲   

 
Price & Availability of ATTINY22L-1SI

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X